Create a Counter Variable in a Flow
There may be a need to keep a counter in a flow, to keep track of how many times an action is performed or for other purposes.
One can create a variable (refer to Flow variables vs Contact variables document to know more about how variables are created in a flow.)and increment it with expression.
1 . Initialize the variable with an update contact node.
2 . Use the update contact node to create a variable and in the result section add 1 to increment the counter.
In this example, a variable counter is created and in the result section, it is incremented by 1. ( <%= @contact.fields.counter+ 1 %>
)
The value of the variable counter can be fetched anywhere with syntax @contact.fields.counter
Split By expression node to check how many times the counter has been incremented.
Then in the flow, you can use it anywhere where you want to repeat things. One of the common use cases is when you nudge the users in case of no response.